package model.elements.commands;

import model.elements.Element2D;
import model.exceptions.ModelExceptions;
import model.map.ElementsMap;

/**
 * The Class ElementDrop.
 * Genera un comando que al ser executado agrega un drop al mapa 
 */
public class ElementDrop implements ElementCommand
{
	
	/** El drop. */
	private Element2D m_drop;
	
	/** El mapa. */
	ElementsMap 			m_map;
	
	/**
	 * Inicializa un comando de drop.
	 *
	 * @param map El mapa
	 * @param drop El drop
	 */
	public ElementDrop( ElementsMap map, Element2D drop )
	{
		m_map = map;
		m_drop = drop;		
	}
	
	/* (non-Javadoc)
	 * @see model.elements.commands.ElementCommand#execute(model.elements.Element2D)
	 */
	@Override
	public void execute( Element2D element ) throws ModelExceptions
	{
	    m_drop.getPosition().setX( element.getPosition().getRealX() );
	    m_drop.getPosition().setY( element.getPosition().getRealY() );
	    m_map.addElement( m_drop );
	}
}
